<?php 
if ($section == "view_comments") $id = $row_view_specific['id']; else $id = $id;

if ($vid != "default") {
	$version_info = explode("*",get_latest_version($dbTable,$cid));
	$query_content_version = sprintf("SELECT vid FROM %s WHERE cid='%s' ORDER BY vid DESC LIMIT 1", $dbTable, $cid);
	$content_version = mysql_query($query_content_version, $connection) or die(mysql_error());
	$row_content_version = mysql_fetch_assoc($content_version);
	$totalRows_content_version = mysql_num_rows($content_version);
}

$query_comments = sprintf("SELECT * FROM comments WHERE cid='%s' AND tableName='%s' AND rid='%s'", $cid, $dbTable, $id);
$comments = mysql_query($query_comments, $connection) or die(mysql_error());
$row_comments = mysql_fetch_assoc($comments);
$totalRows_comments = mysql_num_rows($comments);

?>
<table class="dataTable">
<tr>
	<th width="10%" nowrap="nowrap">ID/Reviewer</th>
    <th>Comment(s)</th>
    <th width="20%">Changes Needed?</th>
</tr>
<?php do { 
$query_id = sprintf("SELECT * FROM users WHERE id='%s'", $row_comments['uid']);
$id = mysql_query($query_id, $connection) or die(mysql_error());
$row_id = mysql_fetch_assoc($id);
$totalRows_id = mysql_num_rows($id);
?>
<tr style="background-color: <?php echo $color; ?>">
	<td width="5%" nowrap="nowrap"><p><?php echo $row_id['firstName']." ".$row_id['lastName']; ?><p></td>
    <td class="data"><?php echo $row_comments['comment']; if ($row_user['userLevel'] <= "2") { ?>
    <div class="stacked">
    <span class="icon"><img src="images/page_edit.png" align="absmiddle" border="0"></span><a href="index.php?section=comments&amp;action=edit&amp;go=<?php echo $go; ?>&amp;view=<?php echo $view; ?>&amp;dbTable=<?php echo $dbTable; ?>&amp;cid=<?php echo $cid; ?>&amp;id=<?php echo $row_comments['id']; ?>&amp;modal_window=<?php echo $modal_window; ?>">Edit</a>
	</div>
    <div class="stacked">
    <span class="icon"><img src="images/bin_closed.png" border="0" align="absmiddle" /></span><a href="javascript:confirmation('includes/process.inc.php?action=delete&dbTable=comments','id','<?php echo $row_comments['id']; ?>','Are you sure want to delete this comment?')">Delete?</a>
    </div>
	<?php } ?></td>
    <td class="data">
	<?php if ($version_info[1] == $row_content_version['vid']) echo changes_needed($row_comments['changes']); else echo "Version out of date." ?>
    </td>
</tr>
<?php if ($color == $color1) { $color = $color2; } else { $color = $color1; } ?>
<?php } while ($row_comments = mysql_fetch_assoc($comments)); ?>
</table>
<h2>Comment Regarding...</h2>
<?php 
if ($dbTable == "project_deliverable") 		include (PROPOSAL.'display_proj_deliv.sec.php');
elseif ($dbTable == "learning_outcomes")	include (PROPOSAL.'display_lo.sec.php');
elseif ($dbTable == "course_description") 	include (PROPOSAL.'display_cd.sec.php'); 
elseif ($dbTable == "course_project")		include (PROPOSAL.'display_cpd.sec.php'); 
elseif ($dbTable == "materials")			include (PROPOSAL.'display_materials.sec.php');
elseif ($dbTable == "readings")				include (MODULES.'display_module_readings.sec.php');
elseif ($dbTable == "assignments")			include (MODULES.'display_module_assignments.sec.php');
elseif ($dbTable == "themes")				include (MODULES.'display_module_themes.sec.php');
?>